<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.ti_advinfo.*" %>
<%@page import="com.lmpop.frame.util.PageTools" %>
<%@page import="com.lmpop.trade.ti_advpara.*" %>

	<%
	Ti_advpara ti_advpara = new Ti_advpara();
	Hashtable ti_advinfo = new Hashtable();
	request.setCharacterEncoding("UTF-8");
	String _adv_title="",_pos_id="",start_start_date="",start_end_date="",end_start_date="",end_end_date="";
	String g_cust_id = "";	
	if( session.getAttribute("session_cust_id") != null ){
		g_cust_id = session.getAttribute("session_cust_id").toString();
		ti_advpara.setCust_id(g_cust_id);
		ti_advinfo.put("cust_id",g_cust_id);
	}
	if(request.getParameter("n_adv_title")!=null && !request.getParameter("n_adv_title").equals("")){
		String adv_title = request.getParameter("n_adv_title");
		_adv_title=adv_title;
		ti_advinfo.put("adv_title",adv_title);
	}
	if(request.getParameter("pos_idx")!=null && !request.getParameter("pos_idx").equals("")){
		String pos_id = request.getParameter("pos_idx");
		_pos_id=pos_id;
		ti_advinfo.put("pos_id",pos_id);
	}
	if(request.getParameter("start_start_date")!=null && !request.getParameter("start_start_date").equals("")){
  		start_start_date = request.getParameter("start_start_date");
		ti_advinfo.put("start_start_date",start_start_date);
	}
	if(request.getParameter("start_end_date")!=null && !request.getParameter("start_end_date").equals("")){
  		start_end_date = request.getParameter("start_end_date");
		ti_advinfo.put("start_end_date",start_end_date);
	}
	if(request.getParameter("end_start_date")!=null && !request.getParameter("end_start_date").equals("")){
  		end_start_date = request.getParameter("end_start_date");
		ti_advinfo.put("end_start_date",end_start_date);
	}
	if(request.getParameter("end_end_date")!=null && !request.getParameter("end_end_date").equals("")){
  		end_end_date = request.getParameter("end_end_date");
		ti_advinfo.put("end_end_date",end_end_date);
	}
	Ti_advinfoInfo ti_advinfoInfo = new Ti_advinfoInfo();
	String iStart = "0";
	int limit = 20;
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	List list = ti_advinfoInfo.getListByPage(ti_advinfo,Integer.parseInt(iStart),limit);
	int counter = ti_advinfoInfo.getCountByObj(ti_advinfo);
	//out.print(list);
	//String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?adv_title="+_adv_title+"&pos_idx"+_pos_id+"&iStart=",Integer.parseInt(iStart),limit);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?adv_title="+_adv_title+"&pos_idx="+_pos_id+"&start_start_date="+start_start_date+"&start_end_date="+start_end_date+"&end_start_date="+end_start_date+"&end_end_date="+end_end_date+"&iStart=",Integer.parseInt(iStart),limit);
	String advSelect = new Ti_advparaInfo().getAdvparaSelected(ti_advpara);
	Map pos_Name = new Ti_advparaInfo().getAll(ti_advpara);
	String para =	"n_adv_title="+_adv_title+"&pos_idx="+_pos_id+"&start_start_date="+start_start_date+"&start_end_date="+start_end_date+"&end_start_date="+end_start_date+"&end_end_date="+end_end_date+"&iStart="+Integer.parseInt(iStart)+"&limit="+limit;
%>
<html>
  <head>
    
    <title>广告信息管理</title>
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="/js/commen.js"></script>
	<script type="text/javascript" src="/program/plugins/calendar/WdatePicker.js"></script>
	<script type="text/javascript" src="js_advInfo.js"></script> 
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1>广告信息管理</h1>
			</td>
			<td>
				<a href="addInfo.jsp"><img src="/program/admin/index/images/post.gif" /></a>
			</td>
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">
	
	<table width="100%" cellpadding="0" cellspacing="0" class="dl_su">
		<tr>
			<td align="left" >
				<div>
				&nbsp;广告标题:<input name="n_adv_title" id="n_adv_title"  style="width:200px;" type="text" maxLength="50"/>
				
				&nbsp;展示开始时间:
										
											
				<input name="start_start_date" type="text" id="txtStartDate" class="Wdate" value="" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'txtEndDate\',{d:-1})}',readOnly:true})" size="15" />
					- 
				<input name="start_end_date" id="txtEndDate" type="text" class="Wdate" value="" onclick="WdatePicker({minDate:'#F{$dp.$D(\'txtStartDate\',{d:1})}',readOnly:true})" size="15"/>
					
				
			</div>
			<div>
				&nbsp;广&nbsp;告&nbsp;位:<select name="pos_idx" id="pos_idx"  style="width:200px;">
												<option value="">请选择</option>
												<%=advSelect%>
										</select>
											
				&nbsp;展示结束时间:
				 <input name="end_start_date" type="text" id="txtStartDate1" class="Wdate" value="" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'txtEndDate1\',{d:-1})}',readOnly:true})" size="15" />
					- 
				<input name="end_end_date" id="txtEndDate1" type="text" class="Wdate" value="" onclick="WdatePicker({minDate:'#F{$dp.$D(\'txtStartDate1\',{d:1})}',readOnly:true})" size="15"/>
					<input name="searchInfo" type="button" value="搜索" onclick="searchForm()"/>
			</div>
			
			</td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" class="tablehe" border="0">
		<tr><td align="center" bgcolor="#ECE6E6"><%=pageString %></td></tr>
	</table>
	
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	
	<table width="100%" cellpadding="0" cellspacing="0" class="dl_bg" border="0">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfo()" value="删除" class="buttab"/>
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th width="5%" align="center"><input type="checkbox" name="checkall" id="checkall" onclick="selectAll()"></th>
		  	<th>广告标题</th>
		  	<th>广告位</th>
		  	<th width="15%">开始时间</th>
		  	<th width="15%">结束时间</th>
		  	<th width="5%">修改</th>
	  		<th width="5%">删除</th>
		</tr>
		<% 
		  		for(int i=0;i<list.size();i++){
		  			Hashtable map = (Hashtable)list.get(i);
					String adv_id="",
					cust_id="",
					adv_title="",
					pos_id="",
					adv_src="",
					adv_text="",
					start_date="",
					end_date="",
					adv_url="",
					contact="",
					contact_info="",
					in_date="",
					user_id="",
					remark="";
					String pos_name ="";
				if(map.get("adv_id")!=null) adv_id = map.get("adv_id").toString();
  				if(map.get("cust_id")!=null) cust_id = map.get("cust_id").toString();
  				if(map.get("adv_title")!=null) adv_title = map.get("adv_title").toString();
  				if(adv_title.length()>20){adv_title=adv_title.substring(0,20);}
  				if(map.get("pos_id")!=null) pos_id = map.get("pos_id").toString();
  				if(pos_id!=null){	pos_name = (String)pos_Name.get(pos_id);   }

  				if(map.get("adv_src")!=null) adv_src = map.get("adv_src").toString();
  				if(map.get("adv_text")!=null) adv_text = map.get("adv_text").toString();
  				if(map.get("start_date")!=null) start_date = map.get("start_date").toString();
    			if(start_date.length()>19)start_date=start_date.substring(0,19);
  				if(map.get("end_date")!=null) end_date = map.get("end_date").toString();
    			if(end_date.length()>19)end_date=end_date.substring(0,19);
  				if(map.get("adv_url")!=null) adv_url = map.get("adv_url").toString();
  				if(map.get("contact")!=null) contact = map.get("contact").toString();
  				if(map.get("contact_info")!=null) contact_info = map.get("contact_info").toString();
  				//if(map.get("in_date")!=null) in_date =map.get("in_date").toString();
    			if(in_date.length()>19)in_date=in_date.substring(0,19);
  				if(map.get("user_id")!=null) user_id = map.get("user_id").toString();
  				if(map.get("remark")!=null) remark = map.get("remark").toString();

		  %>
		
		<tr>
			<td width="5%" align="center"><input type="checkbox" name="checkone<%=i %>" id="checkone<%=i %>" value="<%=adv_id %>" /></td>
			
		  	<td><a href="updateInfo.jsp?adv_id=<%=adv_id %>"><%=adv_title%></a></td>
		  	
		  	<td><a href="index.jsp?pos_idx=<%=pos_id %>"><%=pos_name%></td>
		  	
		  	<td width="15%"><%=start_date%></td>
		  	
		  	<td width="15%"><%=end_date%></td>
		  	
			<td width="5%"><a href="updateInfo.jsp?adv_id=<%=adv_id %>&<%=para%>"><img border="0" src="/program/admin/images/edit.gif" title="修改" /></a></td>
	  		<td width="5%"><a href="javascript:delOneNews('<%=adv_id%>');"><img border="0" src="/program/admin/images/delete.gif" title="删除" /></a></td>
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
		<table width="100%" cellpadding="0" cellspacing="0" class="dl_bg" border="0">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfo()" value="删除" class="buttab"/>
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td align="center" bgcolor="#ECE6E6"><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	  <input type="hidden" name="pkid" id="pkid" value="" />
	  <input type="hidden" name="bpm_id" id="bpm_id" value="8201" />
	  </form>
</body>

</html>
